package net.rlair.sbdemo.aspect;

import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 切面1.
 *
 * @author zhouliangjun
 * @version 1.0.0.0
 */
@Component
@Aspect
@Order(1)
public class ZhouLiangJunAspect1 implements Ordered {

    @Override
    public int getOrder() {
        return 1;
    }

    @Pointcut("execution(* net.rlair.sbdemo.controller.UserController.list(..))")
    public void pointCut() {
    }

    /**
     * 前置通知：目标方法执行之前执行以下方法体的内容
     */
    @Before("pointCut()")
    public void before() {
        System.out.println("Aspect before ......");
    }

    /**
     * 后置通知：目标方法执行之后执行以下方法体的内容，不管是否发生异常
     */
    @After("pointCut()")
    public void after() {
        System.out.println("Aspect after ......");
    }

    /**
     * 异常通知：目标方法发生异常的时候执行以下代码
     */
    @AfterThrowing("pointCut()")
    public void afterThrowing() {
        System.out.println("Aspect afterThrowing ......");
    }

}
